package main

import (
	"fmt"
	"strings"
	"time"
)

const (
	BASE_TIME_FORMAT = "2006-01-02 15:04:05"
)

func main() {
	filename := "a.txt.doc"
	slic := strings.Split(filename, ".")
	fmt.Printf("[%s] file type is [%s] \n", filename, slic[len(slic)-1])
	strDate := "2019-04-01 12:00:03"
	location, err := time.Parse(BASE_TIME_FORMAT, strDate)
	if err != nil {
		fmt.Printf("error = %v", err.Error())
	}
	fmt.Printf("字符串时间-> 类型:%T 值:%v \n", location, location)

	strDate1 := "2020-09-12 12:00:01"
	strDate2 := "2020-09-12 12:00:02"
	time1, _ := time.ParseInLocation(BASE_TIME_FORMAT, strDate1, time.Local)
	time2, _ := time.ParseInLocation(BASE_TIME_FORMAT, strDate2, time.Local)
	before := time1.Before(time2)
	fmt.Printf("%v is before %v ? %t \n\n", time1, time2, before)

	before = time1.Before(location)
	fmt.Printf("%v is before %v ? %t \n", time1, location, before)

	format := time.Now().Format("2006-01-02 15:04:05")
	fmt.Printf("当前时间(Y-m-d H:i:s): %v\n", format)

}
